package com.bblocks.common;


import com.bblocks.common.data.SwaggerHead;
import com.pig4cloud.pig.common.core.constant.CommonConstants;
import org.springframework.http.HttpHeaders;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

public class Constant {

	/**
	 * 大应用前缀
	 * 后续会用到BB_xxx等
	 */
	public static final String SYS_PRE = "BB";

    /** 登录用户标识 **/
    public static final String USER = SYS_PRE + "_USER";

	/**
	 *
	 */
	public static final String MESSAGE_SOURCE = "bbMessageSource";

	public static final String SECURITY_MESSAGE_SOURCE = "securityMessageSource";



	/**
	 * 当前切换的用户的roleId
	 */
	public static final String USER_ROLE_ID = SYS_PRE + "_USER_ROLE_ID";
	/**
	 * 当前切换的用户的roleId 对应code
	 */
	public static final String USER_ROLE_CODE = SYS_PRE + "_USER_ROLE_CODE";
	/**
	 * 当前切换的用户所属公司
	 */
	public static final String USER_COMPANY_ID = SYS_PRE + "_USER_COMPANY_ID";
	/**
	 * 角色/职务 id
	 */
	public static final String COMPANY_USER_ID = SYS_PRE + "_COMPANY_USER_ID";
	/**
	 * USER_COMPANY_ID角色 关联的岗位ID
	 */
	public static final String RELATED_USER_COMPANY_ID = SYS_PRE +  "_RELATED_USER_COMPANY_ID";

	/**
	 * head域名放置的城市code
	 */
	public static final String CITY_CODE = "YZ_CITY_CODE";
	/**
	 * head域名token（ACCESS_TOKEN/HttpHeaders.AUTHORIZATION）
	 */
	public static final String ACCESS_TOKEN_KEY = HttpHeaders.AUTHORIZATION;

	/**
	 * head域名放置请求ID(目前暂未送，本地生成)
	 */
	public static final String REQ_SEQUENCE_KEY = "REQ_SEQUENCE";

	/**
	 * 请求开始时间
	 */
	public static final String REQUEST_START_TIME = "REQUEST-START-TIME";

	/**
	 * 商家端token 前缀
	 */
	public static final String MER_TOKEN_PRE = "YZM_";

    /**
     * 图片的公网地址
     */
    public static final String IMG_PUB_URL = "1";
    /**
     * 图片的自己服务器地址
     */
    public static final String IMG_PRIV_URL = "2";

	/**
	 * 使用渠道 app 和 wx
	 */
	public static final String LOGIN_CHN_APP = "app";
	public static final String LOGIN_CHN_WX = "wx";

    /**
     * 派单类型房产id
     */
    public static final String DISPATCH_TYPE_HOUSE = "470b9620c3284b2c92654cfb1e16bbd7";


    //         派单状态
    /**
     * 已审核
     */
    public static final String dispatch_audit = "1";

    /**
     * 派单待确认
     */
    public static final String dispatch_send = "2";

    /**
     * 派单已确认
     */
    public static final String dispatch_send_ok = "3";

    /**
     * 待抢单
     */
    public static final String dispatch_rod = "4";

    /**
     * 已抢单
     */
    public static final String dispatch_rod_ok = "5";

    /**
     * 已成交
     */
    public static final String dispatch_notarize = "6";

    /**
     * 成交确认
     */
    public static final String dispatch_notarize_ok = "7";

    /**
     * 已评价
     */
    public static final String dispatch_over = "8";

    /**
     * 审核不通过
     */
    public static final String dispatch_auditNot = "9";

    /**
     * 成交驳回
     */
    public static final String dispatch_reject = "10";

    /**
     * 接单
     */
    public static final String dispatch_status_ok = "1";

    /**
     * 拒绝
     */
    public static final String dispatch_status_no = "2";

    /**
     * 派单交易凭证身份证正面照
     */
    public static final String dispatch_document_type_id_r = "0";

    /**
     * 派单交易凭证身份证反面照
     */
    public static final String dispatch_document_type_id_l = "1";

    /**
     * 派单交易凭证
     */
    public static final String dispatch_document_type_id_e = "2";

    /**
     * 派单交易凭证评论图片
     */
    public static final String dispatch_document_type_id_c = "3";


    /**
     * 产业类型
     * 0-写字楼;1-产业园;2-共享办公;3-商铺/商业....
     *
     */
    public static final int OFFICE_BUILDING = 0;
    public static final int PIONEER_PARK = 1;
    public static final int SHARED_OFFICE = 2;
    public static final int SHOP = 3;


    /**
     * 账户账单类型 字典key 系统参数
     */
    public static final String ACC_ORDER_TYPE_KEY = "ACC_ORDER_TYPE_KEY";

    /**
     * 提现限制 参数KEyY
     */
    public static final String ACC_WITHDRAW_LIMIT_KEY = "ACC_WITHDRAW_LIMIT_KEY";

    /**
     * 生活圈顶级menu key
     */
    public static final String YZ_SYS_SHQ_MENU_KEY = "YZ_SYS_SHQ_MENU_KEY";

	/**
	 * 提现说明 key
	 */
	public static final String YZ_WITHDRAWAL_NOTE_KEY = "YZ_WITHDRAWAL_NOTE_KEY";
	/**
	 * 默认城市codekey （暂定南京（320100），后面可以标记未北京）
	 */
	public static final String YZ_SYS_DEFAUL_CITY_CODE_KEY = "YZ_SYS_DEFAUL_CITY_CODE_KEY";
	/**
	 * 普通用户默认角色 key
	 */
	public static final String YZ_SYS_PUBLIC_ROLEID_KEY = "YZ_SYS_PUBLIC_ROLEID_KEY";

	/**
	 * 活动队列开始监听队列名
	 */
	public static final String ACTIVITY_START_LISTENER = "ACTIVITY_START_LISTENER";

	/**
	 * 活动队列结束监听队列名
	 */
	public static final String ACTIVITY_END_LISTENER = "ACTIVITY_END_LISTENER";


	/**
	 * 应用信息头（添加了注解SwaggerHead 才会在swagger文档中（全局参数设置）中出现）
	 */
	public static class AppHead {

		/**
		 * token
		 */
		@SwaggerHead("token,例如：Bearer xxxxxxx")
		public static final String HEAD_TOKEN = Constant.ACCESS_TOKEN_KEY;//token

		/**
		 * 灰度路由版本信息
		 */
		@SwaggerHead("灰度路由版本信息")
		public static final String HEAD_VERSION = CommonConstants.VERSION;//版本号

		@SwaggerHead("响应字段过滤,例如：fielda,fieldb")
		public static final String HEAD_FIELDS = Constant.SYS_PRE + "_FIELDS";//例如：BB_FIELDS

		public static final String HEAD_APP_VERSION = Constant.SYS_PRE + "-APPVERS";//版本号

		public static final String HEAD_APPTYPE = Constant.SYS_PRE +"-APPTYPE";//1-安卓 2-IOS,3-小程序，定义见 AppPlatformTypeEnum

		public static final String HEAD_PID = Constant.SYS_PRE +"-PID";//product id

		public static final String HEAD_APPCHG = Constant.SYS_PRE +"-APPCHG";//app 类型(渠道)

		public static final String HEAD_DEVID = Constant.SYS_PRE +"-DEVID";//设备ID

		public static final String HEAD_SERTAG = Constant.SYS_PRE +"-SERTAG";//指定服务器 （为空则走通用）

		public static final String HEAD_BASE = Constant.SYS_PRE +"-BASE";//当前页面
		//其他参数如：sysversion = 9    mobelversion = MI 8

	}






	public static void main(String[] args) throws Exception{
		Class clazz =  com.bblocks.common.Constant.AppHead.class;

		Field[] declaredFields = clazz.getDeclaredFields();
		for (Field field : declaredFields) {
			field.setAccessible(true);
			if( Modifier.isStatic(field.getModifiers())){
				if(field.isAnnotationPresent(SwaggerHead.class)){
					SwaggerHead swaggerHeadInfo = field.getAnnotation(SwaggerHead.class);
					System.out.println(field.getName()+":"+field.get(clazz)+" 注释："+swaggerHeadInfo.value());
				}
			}
		}
	}

}
